mysql> select * from stu;
+----+--------+-----+------+-------------+
| id | name   | sex | age  | phone       |
+----+--------+-----+------+-------------+
|  1 | 马志斌 |     |   18 | 18925139194 |
+----+--------+-----+------+-------------+
1 row in set (0.02 sec)

mysql> insert into stu (name,sex) value('马志斌','男');
ERROR 1062 (23000): Duplicate entry '马志斌' for key 'name_key'
mysql> insert into stu (name,sex) value('莫九峰','男');
Query OK, 1 row affected (0.07 sec)

mysql> select * from stu;
+----+--------+-----+------+-------------+
| id | name   | sex | age  | phone       |
+----+--------+-----+------+-------------+
|  1 | 马志斌 |     |   18 | 18925139194 |
|  3 | 莫九峰 | 男  |   18 | 18925139194 |
+----+--------+-----+------+-------------+
2 rows in set (0.00 sec)

mysql> insert into stu (name) value('小平平');
Query OK, 1 row affected (0.08 sec)

mysql> select * from stu;
+----+--------+-----+------+-------------+
| id | name   | sex | age  | phone       |
+----+--------+-----+------+-------------+
|  1 | 马志斌 |     |   18 | 18925139194 |
|  3 | 莫九峰 | 男  |   18 | 18925139194 |
|  4 | 小平平 | 妖  |   18 | 18925139194 |
+----+--------+-----+------+-------------+
3 rows in set (0.00 sec)

mysql> insert into stu (name,age) value('海公公',19);
Query OK, 1 row affected (0.10 sec)

mysql> select * from stu;
+----+--------+-----+------+-------------+
| id | name   | sex | age  | phone       |
+----+--------+-----+------+-------------+
|  1 | 马志斌 |     |   18 | 18925139194 |
|  3 | 莫九峰 | 男  |   18 | 18925139194 |
|  4 | 小平平 | 妖  |   18 | 18925139194 |
|  5 | 海公公 | 妖  |   19 | 18925139194 |
+----+--------+-----+------+-------------+
4 rows in set (0.00 sec)

mysql> select * from stu;
+----+--------+-----+------+-------------+
| id | name   | sex | age  | phone       |
+----+--------+-----+------+-------------+
|  1 | 马志斌 |     |   18 | 18925139194 |
|  3 | 莫九峰 | 男  |   18 | 18925139194 |
|  4 | 小平平 | 妖  |   18 | 18925139194 |
|  5 | 海公公 | 妖  |   19 | 18925139194 |
+----+--------+-----+------+-------------+
4 rows in set (0.00 sec)

mysql> select name from stu;
+--------+
| name   |
+--------+
| 小平平 |
| 海公公 |
| 莫九峰 |
| 马志斌 |
+--------+
4 rows in set (0.00 sec)

mysql> select age from stu;
+------+
| age  |
+------+
|   18 |
|   18 |
|   18 |
|   19 |
+------+
4 rows in set (0.00 sec)

mysql> select name,age from stu;
+--------+------+
| name   | age  |
+--------+------+
| 马志斌 |   18 |
| 莫九峰 |   18 |
| 小平平 |   18 |
| 海公公 |   19 |
+--------+------+
4 rows in set (0.00 sec)

mysql> select name as n,age as a from stu;
+--------+------+
| n      | a    |
+--------+------+
| 马志斌 |   18 |
| 莫九峰 |   18 |
| 小平平 |   18 |
| 海公公 |   19 |
+--------+------+
4 rows in set (0.00 sec)

mysql> select name n,age a from stu;
+--------+------+
| n      | a    |
+--------+------+
| 马志斌 |   18 |
| 莫九峰 |   18 |
| 小平平 |   18 |
| 海公公 |   19 |
+--------+------+
4 rows in set (0.00 sec)

mysql> select * from stu ;
+----+--------+-----+------+-------------+
| id | name   | sex | age  | phone       |
+----+--------+-----+------+-------------+
|  1 | 马志斌 |     |   18 | 18925139194 |
|  3 | 莫九峰 | 男  |   18 | 18925139194 |
|  4 | 小平平 | 妖  |   18 | 18925139194 |
|  5 | 海公公 | 妖  |   19 | 18925139194 |
+----+--------+-----+------+-------------+
4 rows in set (0.00 sec)

mysql> select * from stu where id=5;
+----+--------+-----+------+-------------+
| id | name   | sex | age  | phone       |
+----+--------+-----+------+-------------+
|  5 | 海公公 | 妖  |   19 | 18925139194 |
+----+--------+-----+------+-------------+
1 row in set (0.00 sec)

mysql> select * from stu where id<3;
+----+--------+-----+------+-------------+
| id | name   | sex | age  | phone       |
+----+--------+-----+------+-------------+
|  1 | 马志斌 |     |   18 | 18925139194 |
+----+--------+-----+------+-------------+
1 row in set (0.00 sec)

mysql> select * from stu where id<5 and age>18;
Empty set (0.00 sec)

mysql> select * from stu where id<6 and age>18;
+----+--------+-----+------+-------------+
| id | name   | sex | age  | phone       |
+----+--------+-----+------+-------------+
|  5 | 海公公 | 妖  |   19 | 18925139194 |
+----+--------+-----+------+-------------+
1 row in set (0.00 sec)

mysql> select * from stu where id<5 or age>18;
+----+--------+-----+------+-------------+
| id | name   | sex | age  | phone       |
+----+--------+-----+------+-------------+
|  1 | 马志斌 |     |   18 | 18925139194 |
|  3 | 莫九峰 | 男  |   18 | 18925139194 |
|  4 | 小平平 | 妖  |   18 | 18925139194 |
|  5 | 海公公 | 妖  |   19 | 18925139194 |
+----+--------+-----+------+-------------+
4 rows in set (0.00 sec)

mysql> select * from stu where id<5 or age>19;
+----+--------+-----+------+-------------+
| id | name   | sex | age  | phone       |
+----+--------+-----+------+-------------+
|  1 | 马志斌 |     |   18 | 18925139194 |
|  3 | 莫九峰 | 男  |   18 | 18925139194 |
|  4 | 小平平 | 妖  |   18 | 18925139194 |
+----+--------+-----+------+-------------+
3 rows in set (0.00 sec)

mysql> select concat(name,sex) from stu where id<5 or age>19;
+------------------+
| concat(name,sex) |
+------------------+
| 马志斌           |
| 莫九峰男         |
| 小平平妖         |
+------------------+
3 rows in set (0.03 sec)

mysql> select * from stu ;
+----+--------+-----+------+-------------+
| id | name   | sex | age  | phone       |
+----+--------+-----+------+-------------+
|  1 | 马志斌 |     |   18 | 18925139194 |
|  3 | 莫九峰 | 男  |   18 | 18925139194 |
|  4 | 小平平 | 妖  |   18 | 18925139194 |
|  5 | 海公公 | 妖  |   19 | 18925139194 |
+----+--------+-----+------+-------------+
4 rows in set (0.00 sec)

mysql> select distinct(age) from stu ;
+------+
| age  |
+------+
|   18 |
|   19 |
+------+
2 rows in set (0.00 sec)

mysql> select * from stu where sex='男';
+----+--------+-----+------+-------------+
| id | name   | sex | age  | phone       |
+----+--------+-----+------+-------------+
|  3 | 莫九峰 | 男  |   18 | 18925139194 |
+----+--------+-----+------+-------------+
1 row in set (0.00 sec)

mysql> alter table stu add hobby set('看书','打球','拍黄片') default '拍黄片';
Query OK, 0 rows affected (0.41 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc stu;
+-------+-----------------------------+------+-----+-------------+----------------+
| Field | Type                        | Null | Key | Default     | Extra          |
+-------+-----------------------------+------+-----+-------------+----------------+
| id    | int(6)                      | NO   | PRI | NULL        | auto_increment |
| name  | varchar(50)                 | YES  | UNI |             |                |
| sex   | enum('男','女','妖')        | NO   |     | 妖          |                |
| age   | int(3)                      | YES  |     | 18          |                |
| phone | varchar(11)                 | NO   |     | 18925139194 |                |
| hobby | set('看书','打球','拍黄片') | YES  |     | 拍黄片      |                |
+-------+-----------------------------+------+-----+-------------+----------------+
6 rows in set (0.00 sec)

mysql> select * from stu;
+----+--------+-----+------+-------------+--------+
| id | name   | sex | age  | phone       | hobby  |
+----+--------+-----+------+-------------+--------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 |
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 |
+----+--------+-----+------+-------------+--------+
4 rows in set (0.00 sec)

mysql> select * from stu where hobby='拍黄片';
+----+--------+-----+------+-------------+--------+
| id | name   | sex | age  | phone       | hobby  |
+----+--------+-----+------+-------------+--------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 |
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 |
+----+--------+-----+------+-------------+--------+
4 rows in set (0.00 sec)

mysql> select * from stu where find_in_set('拍黄片',hobby);
+----+--------+-----+------+-------------+--------+
| id | name   | sex | age  | phone       | hobby  |
+----+--------+-----+------+-------------+--------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 |
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 |
+----+--------+-----+------+-------------+--------+
4 rows in set (0.07 sec)

mysql> select * from stu where hobby &4;
+----+--------+-----+------+-------------+--------+
| id | name   | sex | age  | phone       | hobby  |
+----+--------+-----+------+-------------+--------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 |
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 |
+----+--------+-----+------+-------------+--------+
4 rows in set (0.00 sec)

mysql> select * from stu where hobby &3;
Empty set (0.00 sec)

mysql> select * from stu where hobby &2;
Empty set (0.00 sec)

mysql> select * from stu where hobby &1;
Empty set (0.00 sec)

mysql> insert into stu (name,age,hobby) value('小伙伴',19,'打球');
Query OK, 1 row affected (0.20 sec)

mysql> select * from  stu
    -> ;
+----+--------+-----+------+-------------+--------+
| id | name   | sex | age  | phone       | hobby  |
+----+--------+-----+------+-------------+--------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 |
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 |
|  6 | 小伙伴 | 妖  |   19 | 18925139194 | 打球   |
+----+--------+-----+------+-------------+--------+
5 rows in set (0.00 sec)

mysql> select * from stu where hobby &4;
+----+--------+-----+------+-------------+--------+
| id | name   | sex | age  | phone       | hobby  |
+----+--------+-----+------+-------------+--------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 |
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 |
+----+--------+-----+------+-------------+--------+
4 rows in set (0.00 sec)

mysql> select * from stu where hobby &3;
+----+--------+-----+------+-------------+-------+
| id | name   | sex | age  | phone       | hobby |
+----+--------+-----+------+-------------+-------+
|  6 | 小伙伴 | 妖  |   19 | 18925139194 | 打球  |
+----+--------+-----+------+-------------+-------+
1 row in set (0.00 sec)

mysql> desc stu;
+-------+-----------------------------+------+-----+-------------+----------------+
| Field | Type                        | Null | Key | Default     | Extra          |
+-------+-----------------------------+------+-----+-------------+----------------+
| id    | int(6)                      | NO   | PRI | NULL        | auto_increment |
| name  | varchar(50)                 | YES  | UNI |             |                |
| sex   | enum('男','女','妖')        | NO   |     | 妖          |                |
| age   | int(3)                      | YES  |     | 18          |                |
| phone | varchar(11)                 | NO   |     | 18925139194 |                |
| hobby | set('看书','打球','拍黄片') | YES  |     | 拍黄片      |                |
+-------+-----------------------------+------+-----+-------------+----------------+
6 rows in set (0.01 sec)

mysql> select * from stu where hobby &5;
+----+--------+-----+------+-------------+--------+
| id | name   | sex | age  | phone       | hobby  |
+----+--------+-----+------+-------------+--------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 |
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 |
+----+--------+-----+------+-------------+--------+
4 rows in set (0.00 sec)

mysql> select * from stu where hobby &6;
+----+--------+-----+------+-------------+--------+
| id | name   | sex | age  | phone       | hobby  |
+----+--------+-----+------+-------------+--------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 |
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 |
|  6 | 小伙伴 | 妖  |   19 | 18925139194 | 打球   |
+----+--------+-----+------+-------------+--------+
5 rows in set (0.00 sec)

mysql> select * from stu where hobby like '黄片';
Empty set (0.00 sec)

mysql> select * from stu where hobby like '%黄片%';
+----+--------+-----+------+-------------+--------+
| id | name   | sex | age  | phone       | hobby  |
+----+--------+-----+------+-------------+--------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 |
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 |
+----+--------+-----+------+-------------+--------+
4 rows in set (0.00 sec)

mysql> select * from stu where hobby like '%黄片';
+----+--------+-----+------+-------------+--------+
| id | name   | sex | age  | phone       | hobby  |
+----+--------+-----+------+-------------+--------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 |
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 |
+----+--------+-----+------+-------------+--------+
4 rows in set (0.00 sec)

mysql> select * from stu where hobby like '%黄';
Empty set (0.00 sec)

mysql> desc stu;
+-------+-----------------------------+------+-----+-------------+----------------+
| Field | Type                        | Null | Key | Default     | Extra          |
+-------+-----------------------------+------+-----+-------------+----------------+
| id    | int(6)                      | NO   | PRI | NULL        | auto_increment |
| name  | varchar(50)                 | YES  | UNI |             |                |
| sex   | enum('男','女','妖')        | NO   |     | 妖          |                |
| age   | int(3)                      | YES  |     | 18          |                |
| phone | varchar(11)                 | NO   |     | 18925139194 |                |
| hobby | set('看书','打球','拍黄片') | YES  |     | 拍黄片      |                |
+-------+-----------------------------+------+-----+-------------+----------------+
6 rows in set (0.00 sec)

mysql>
mysql> 妖
    -> 18
    -> 1892513
    ->     -> Ctrl-C -- exit!

    -> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to you
18
1892513' at line 1
mysql> alter table stu add address varchar(20);
Query OK, 0 rows affected (0.43 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> select * from stu;
+----+--------+-----+------+-------------+--------+---------+
| id | name   | sex | age  | phone       | hobby  | address |
+----+--------+-----+------+-------------+--------+---------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 | NULL    |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 | NULL    |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 | NULL    |
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 | NULL    |
|  6 | 小伙伴 | 妖  |   19 | 18925139194 | 打球   | NULL    |
+----+--------+-----+------+-------------+--------+---------+
5 rows in set (0.00 sec)

mysql> select * from stu where address is null
    -> ;
+----+--------+-----+------+-------------+--------+---------+
| id | name   | sex | age  | phone       | hobby  | address |
+----+--------+-----+------+-------------+--------+---------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 | NULL    |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 | NULL    |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 | NULL    |
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 | NULL    |
|  6 | 小伙伴 | 妖  |   19 | 18925139194 | 打球   | NULL    |
+----+--------+-----+------+-------------+--------+---------+
5 rows in set (0.00 sec)

mysql> select * from stu where address is not null;
Empty set (0.00 sec)

mysql> select name,age,if(age>18,'成年','刚好成年') s from stu;
+--------+------+----------+
| name   | age  | s        |
+--------+------+----------+
| 马志斌 |   18 | 刚好成年 |
| 莫九峰 |   18 | 刚好成年 |
| 小平平 |   18 | 刚好成年 |
| 海公公 |   19 | 成年     |
| 小伙伴 |   19 | 成年     |
+--------+------+----------+
5 rows in set (0.00 sec)

mysql> select * from stu order by age desc;
+----+--------+-----+------+-------------+--------+---------+
| id | name   | sex | age  | phone       | hobby  | address |
+----+--------+-----+------+-------------+--------+---------+
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 | NULL    |
|  6 | 小伙伴 | 妖  |   19 | 18925139194 | 打球   | NULL    |
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 | NULL    |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 | NULL    |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 | NULL    |
+----+--------+-----+------+-------------+--------+---------+
5 rows in set (0.00 sec)

mysql> select * from stu order by age asc;
+----+--------+-----+------+-------------+--------+---------+
| id | name   | sex | age  | phone       | hobby  | address |
+----+--------+-----+------+-------------+--------+---------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 | NULL    |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 | NULL    |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 | NULL    |
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 | NULL    |
|  6 | 小伙伴 | 妖  |   19 | 18925139194 | 打球   | NULL    |
+----+--------+-----+------+-------------+--------+---------+
5 rows in set (0.00 sec)

mysql> select * from stu order by id desc;
+----+--------+-----+------+-------------+--------+---------+
| id | name   | sex | age  | phone       | hobby  | address |
+----+--------+-----+------+-------------+--------+---------+
|  6 | 小伙伴 | 妖  |   19 | 18925139194 | 打球   | NULL    |
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 | NULL    |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 | NULL    |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 | NULL    |
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 | NULL    |
+----+--------+-----+------+-------------+--------+---------+
5 rows in set (0.00 sec)

mysql> select * from stu limit 1;
+----+--------+-----+------+-------------+--------+---------+
| id | name   | sex | age  | phone       | hobby  | address |
+----+--------+-----+------+-------------+--------+---------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 | NULL    |
+----+--------+-----+------+-------------+--------+---------+
1 row in set (0.00 sec)

mysql> select * from stu limit 2;
+----+--------+-----+------+-------------+--------+---------+
| id | name   | sex | age  | phone       | hobby  | address |
+----+--------+-----+------+-------------+--------+---------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 | NULL    |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 | NULL    |
+----+--------+-----+------+-------------+--------+---------+
2 rows in set (0.00 sec)

mysql> select * from stu limit 3;
+----+--------+-----+------+-------------+--------+---------+
| id | name   | sex | age  | phone       | hobby  | address |
+----+--------+-----+------+-------------+--------+---------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 | NULL    |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 | NULL    |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 | NULL    |
+----+--------+-----+------+-------------+--------+---------+
3 rows in set (0.00 sec)

mysql> select * from stu limit 4;
+----+--------+-----+------+-------------+--------+---------+
| id | name   | sex | age  | phone       | hobby  | address |
+----+--------+-----+------+-------------+--------+---------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 | NULL    |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 | NULL    |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 | NULL    |
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 | NULL    |
+----+--------+-----+------+-------------+--------+---------+
4 rows in set (0.00 sec)

mysql> select * from stu limit (2,2);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version f
mysql> select * from stu limit(2,2);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version f
mysql> select * from stu limit(2,4);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version f
mysql> select * from stu limit(1,2);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version f
mysql> select * from stu limit 1,2;
+----+--------+-----+------+-------------+--------+---------+
| id | name   | sex | age  | phone       | hobby  | address |
+----+--------+-----+------+-------------+--------+---------+
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 | NULL    |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 | NULL    |
+----+--------+-----+------+-------------+--------+---------+
2 rows in set (0.00 sec)

mysql> select * from stu limit 1,3;
+----+--------+-----+------+-------------+--------+---------+
| id | name   | sex | age  | phone       | hobby  | address |
+----+--------+-----+------+-------------+--------+---------+
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 | NULL    |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 | NULL    |
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 | NULL    |
+----+--------+-----+------+-------------+--------+---------+
3 rows in set (0.00 sec)

mysql> select * from stu limit 0,10;
+----+--------+-----+------+-------------+--------+---------+
| id | name   | sex | age  | phone       | hobby  | address |
+----+--------+-----+------+-------------+--------+---------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 | NULL    |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 | NULL    |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 | NULL    |
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 | NULL    |
|  6 | 小伙伴 | 妖  |   19 | 18925139194 | 打球   | NULL    |
+----+--------+-----+------+-------------+--------+---------+
5 rows in set (0.00 sec)

mysql> select * from stu limit 10,10;
Empty set (0.00 sec)

mysql> select * from stu limit 20,10;
Empty set (0.00 sec)

mysql> select * from stu;
+----+--------+-----+------+-------------+--------+---------+
| id | name   | sex | age  | phone       | hobby  | address |
+----+--------+-----+------+-------------+--------+---------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 | NULL    |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 | NULL    |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 | NULL    |
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 | NULL    |
|  6 | 小伙伴 | 妖  |   19 | 18925139194 | 打球   | NULL    |
+----+--------+-----+------+-------------+--------+---------+
5 rows in set (0.00 sec)

mysql> insert into stu (name,age,hobby) value('小小小',10,'打球');
Query OK, 1 row affected (0.07 sec)

mysql> select * from stu;
+----+--------+-----+------+-------------+--------+---------+
| id | name   | sex | age  | phone       | hobby  | address |
+----+--------+-----+------+-------------+--------+---------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 | NULL    |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 | NULL    |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 | NULL    |
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 | NULL    |
|  6 | 小伙伴 | 妖  |   19 | 18925139194 | 打球   | NULL    |
|  7 | 小小小 | 妖  |   10 | 18925139194 | 打球   | NULL    |
+----+--------+-----+------+-------------+--------+---------+
6 rows in set (0.00 sec)

mysql> select * from stu where age <19 and age >11;
+----+--------+-----+------+-------------+--------+---------+
| id | name   | sex | age  | phone       | hobby  | address |
+----+--------+-----+------+-------------+--------+---------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 | NULL    |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 | NULL    |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 | NULL    |
+----+--------+-----+------+-------------+--------+---------+
3 rows in set (0.00 sec)

mysql> select * from stu where age between 11 and 19;
+----+--------+-----+------+-------------+--------+---------+
| id | name   | sex | age  | phone       | hobby  | address |
+----+--------+-----+------+-------------+--------+---------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 | NULL    |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 | NULL    |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 | NULL    |
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 | NULL    |
|  6 | 小伙伴 | 妖  |   19 | 18925139194 | 打球   | NULL    |
+----+--------+-----+------+-------------+--------+---------+
5 rows in set (0.00 sec)

mysql> select * from stu where age between 11 and 18;
+----+--------+-----+------+-------------+--------+---------+
| id | name   | sex | age  | phone       | hobby  | address |
+----+--------+-----+------+-------------+--------+---------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 | NULL    |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 | NULL    |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 | NULL    |
+----+--------+-----+------+-------------+--------+---------+
3 rows in set (0.00 sec)

mysql> select * from stu where age in(19);
+----+--------+-----+------+-------------+--------+---------+
| id | name   | sex | age  | phone       | hobby  | address |
+----+--------+-----+------+-------------+--------+---------+
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 | NULL    |
|  6 | 小伙伴 | 妖  |   19 | 18925139194 | 打球   | NULL    |
+----+--------+-----+------+-------------+--------+---------+
2 rows in set (0.00 sec)

mysql> select * from stu where age in(19,10);
+----+--------+-----+------+-------------+--------+---------+
| id | name   | sex | age  | phone       | hobby  | address |
+----+--------+-----+------+-------------+--------+---------+
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 | NULL    |
|  6 | 小伙伴 | 妖  |   19 | 18925139194 | 打球   | NULL    |
|  7 | 小小小 | 妖  |   10 | 18925139194 | 打球   | NULL    |
+----+--------+-----+------+-------------+--------+---------+
3 rows in set (0.00 sec)

mysql> select * from stu;
+----+--------+-----+------+-------------+--------+---------+
| id | name   | sex | age  | phone       | hobby  | address |
+----+--------+-----+------+-------------+--------+---------+
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 | NULL    |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 | NULL    |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 | NULL    |
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 | NULL    |
|  6 | 小伙伴 | 妖  |   19 | 18925139194 | 打球   | NULL    |
|  7 | 小小小 | 妖  |   10 | 18925139194 | 打球   | NULL    |
+----+--------+-----+------+-------------+--------+---------+
6 rows in set (0.00 sec)

mysql> select left(name,1) from stu;
+--------------+
| left(name,1) |
+--------------+
| 小           |
| 小           |
| 小           |
| 海           |
| 莫           |
| 马           |
+--------------+
6 rows in set (0.00 sec)

mysql> select left(name,2) from stu;
+--------------+
| left(name,2) |
+--------------+
| 小伙         |
| 小小         |
| 小平         |
| 海公         |
| 莫九         |
| 马志         |
+--------------+
6 rows in set (0.00 sec)

mysql> select left(name,3) from stu;
+--------------+
| left(name,3) |
+--------------+
| 小伙伴       |
| 小小小       |
| 小平平       |
| 海公公       |
| 莫九峰       |
| 马志斌       |
+--------------+
6 rows in set (0.00 sec)

mysql> select * from stu order by rand() limit 6;
+----+--------+-----+------+-------------+--------+---------+
| id | name   | sex | age  | phone       | hobby  | address |
+----+--------+-----+------+-------------+--------+---------+
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 | NULL    |
|  1 | 马志斌 |     |   18 | 18925139194 | 拍黄片 | NULL    |
|  4 | 小平平 | 妖  |   18 | 18925139194 | 拍黄片 | NULL    |
|  7 | 小小小 | 妖  |   10 | 18925139194 | 打球   | NULL    |
|  6 | 小伙伴 | 妖  |   19 | 18925139194 | 打球   | NULL    |
|  5 | 海公公 | 妖  |   19 | 18925139194 | 拍黄片 | NULL    |
+----+--------+-----+------+-------------+--------+---------+
6 rows in set (0.09 sec)

mysql> select * from stu order by rand() limit 2;
+----+--------+-----+------+-------------+--------+---------+
| id | name   | sex | age  | phone       | hobby  | address |
+----+--------+-----+------+-------------+--------+---------+
|  7 | 小小小 | 妖  |   10 | 18925139194 | 打球   | NULL    |
|  3 | 莫九峰 | 男  |   18 | 18925139194 | 拍黄片 | NULL    |
+----+--------+-----+------+-------------+--------+---------+
2 rows in set (0.00 sec)

mysql> select * from stu order by rand() limit 1;
+----+--------+-----+------+-------------+-------+---------+
| id | name   | sex | age  | phone       | hobby | address |
+----+--------+-----+------+-------------+-------+---------+
|  6 | 小伙伴 | 妖  |   19 | 18925139194 | 打球  | NULL    |
+----+--------+-----+------+-------------+-------+---------+
1 row in set (0.00 sec)

mysql>












































